import { StringUtils } from '@/utils/StringUtils'

class CStoreUtils {
  constructor() {
    this.URL = ''
  }

  parseUrl(path = '', param = '') {
    const str = [this.URL, path]
    if (!StringUtils.isEmptyOrNull(param)) {
      str.push(...['/', param])
    }
    return str.join('')
  }

  toCamelParams(payload) {
    const _params = payload || {}
    const camlizedParams = {}
    Object.entries(_params).map(([key, value]) => {
      const camleKey = StringUtils.toCamelCase(key)
      camlizedParams[camleKey] = value
    })

    return { ...camlizedParams }
  }
}

export const StoreUtils = (function() {
  return new CStoreUtils()
})()
